/**
 * Generate code from /{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/domain/{{entities@SQL}}.java.hbs
 */
package cn.ibizlab.core.system.domain;

import java.util.*;
import cn.ibizlab.util.domain.IEntity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.*;
import org.springframework.data.annotation.*;
import cn.ibizlab.util.annotation.*;
import cn.ibizlab.util.enums.*;
import cn.ibizlab.util.domain.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import cn.ibizlab.core.authorization.domain.SysRole;
import cn.ibizlab.core.system.domain.SysMenu;
import cn.ibizlab.core.system.domain.SysComponent;
import cn.ibizlab.core.system.domain.SysApi;
import cn.ibizlab.core.system.domain.SysPermission;
import cn.ibizlab.core.system.domain.SysCustomResource;

/**
 * 系统实体类[SysDeploySystem]
 *
 * @author generator
 */
@Audit
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@TableName(value = "SYS_DEPLOY_SYSTEM", resultMap = "SysDeploySystemResultMap")
@ApiModel(value = "SYS_DEPLOY_SYSTEM", description = "系统")
public class SysDeploySystem extends EntityMP implements Serializable
{

    /**
     * 系统标识
     */
    @Id
    @TableId(value = "id" , type = IdType.ASSIGN_UUID)
    @DEField(name = "id" , isKeyField = true)
    @JsonProperty("id")
    @JSONField(name = "id")
    @ApiModelProperty(value = "id", notes = "系统标识")
    private String id;

    /**
     * 系统名
     */
    @TableField(value = "system_id")
    @DEField(name = "system_id")
    @JsonProperty("system_id")
    @JSONField(name = "system_id")
    @ApiModelProperty(value = "system_id", notes = "系统名")
    private String systemId;

    /**
     * 系统显示名称
     */
    @TableField(value = "display_name")
    @DEField(name = "display_name" , defaultValue = "system_id" , defaultValueType = DEFieldDefaultValueType.PARAM)
    @JsonProperty("display_name")
    @JSONField(name = "display_name")
    @ApiModelProperty(value = "display_name", notes = "系统显示名称")
    private String displayName;

    /**
     * 创建人
     */
    @TableField(value = "creator" , fill = FieldFill.INSERT)
    @DEField(name = "creator" , preType = DEPredefinedFieldType.CREATEMAN)
    @JsonProperty("creator")
    @JSONField(name = "creator")
    @ApiModelProperty(value = "creator", notes = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @TableField(value = "create_time" , fill = FieldFill.INSERT)
    @DEField(name = "create_time" , preType = DEPredefinedFieldType.CREATEDATE)
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "create_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "create_time", notes = "创建时间")
    private Date createTime;

    /**
     * 最后更新人
     */
    @TableField(value = "updater")
    @DEField(name = "updater" , preType = DEPredefinedFieldType.UPDATEMAN)
    @JsonProperty("updater")
    @JSONField(name = "updater")
    @ApiModelProperty(value = "updater", notes = "最后更新人")
    private String updater;

    /**
     * 最后更新时间
     */
    @TableField(value = "update_time")
    @DEField(name = "update_time" , preType = DEPredefinedFieldType.UPDATEDATE)
    @JsonProperty("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "update_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "update_time", notes = "最后更新时间")
    private Date updateTime;

    /**
     * DC
     */
    @TableField(value = "dc")
    @DEField(name = "dc")
    @JsonProperty("dc")
    @JSONField(name = "dc")
    @ApiModelProperty(value = "dc", notes = "DC")
    private String dc;

    /**
     * 菜单
     */
    @TableField(value = "menus", jdbcType = org.apache.ibatis.type.JdbcType.VARCHAR, typeHandler = cn.ibizlab.core.system.domain.handlers.SysMenuTypeHandler.class)
    @DEField(name = "menus")
    @JsonProperty("menus")
    @JSONField(name = "menus")
    @ApiModelProperty(value = "menus", notes = "菜单")
    private List<SysMenu> menus;

    /**
     * 组件
     */
    @TableField(value = "components", jdbcType = org.apache.ibatis.type.JdbcType.VARCHAR, typeHandler = cn.ibizlab.core.system.domain.handlers.SysComponentTypeHandler.class)
    @DEField(name = "components")
    @JsonProperty("components")
    @JSONField(name = "components")
    @ApiModelProperty(value = "components", notes = "组件")
    private List<SysComponent> components;

    /**
     * 接口
     */
    @TableField(value = "apis", jdbcType = org.apache.ibatis.type.JdbcType.VARCHAR, typeHandler = cn.ibizlab.core.system.domain.handlers.SysApiTypeHandler.class)
    @DEField(name = "apis")
    @JsonProperty("apis")
    @JSONField(name = "apis")
    @ApiModelProperty(value = "apis", notes = "接口")
    private List<SysApi> apis;

    /**
     * 权限资源
     */
    @TableField(exist = false)
    @DEField(name = "permissions")
    @JsonProperty("permissions")
    @JSONField(name = "permissions")
    @ApiModelProperty(value = "permissions", notes = "权限资源")
    private List<SysPermission> permissions;

    /**
     * 自定义资源
     */
    @TableField(exist = false)
    @DEField(name = "custom_resources")
    @JsonProperty("custom_resources")
    @JSONField(name = "custom_resources")
    @ApiModelProperty(value = "custom_resources", notes = "自定义资源")
    private List<SysCustomResource> customResources;

    /**
     * MD5校验
     */
    @TableField(value = "md5_checksum")
    @DEField(name = "md5_checksum")
    @JsonProperty("md5_checksum")
    @JSONField(name = "md5_checksum")
    @ApiModelProperty(value = "md5_checksum", notes = "MD5校验")
    private String md5Checksum;

    /**
     * 绑定标识
     */
    @TableField(value = "binding_id")
    @DEField(name = "binding_id")
    @JsonProperty("binding_id")
    @JSONField(name = "binding_id")
    @ApiModelProperty(value = "binding_id", notes = "绑定标识")
    private String bindingId;

    /**
     * 描述
     */
    @TableField(value = "description")
    @DEField(name = "description")
    @JsonProperty("description")
    @JSONField(name = "description")
    @ApiModelProperty(value = "description", notes = "描述")
    private String description;

    /**
     * 删除标识
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0" , delval = "1")
    @DEField(name = "deleted" , defaultValue = "0" , preType = DEPredefinedFieldType.LOGICVALID , logicval = "0" , logicdelval = "1" , dict = "YesNo")
    @JsonProperty("deleted")
    @JSONField(name = "deleted")
    @ApiModelProperty(value = "deleted", notes = "删除标识")
    private Integer deleted;

    /**
     * 是否启用标识
     */
    @TableField(value = "enabled")
    @DEField(name = "enabled" , defaultValue = "1" , dict = "YesNo")
    @JsonProperty("enabled")
    @JSONField(name = "enabled")
    @ApiModelProperty(value = "enabled", notes = "是否启用标识")
    private Integer enabled;

    /**
     * 设置 [系统名]
     */
    public SysDeploySystem setSystemId(String systemId) {
        this.systemId = systemId;
        this.modify("system_id", systemId);
        return this;
    }

    /**
     * 设置 [系统显示名称]
     */
    public SysDeploySystem setDisplayName(String displayName) {
        this.displayName = displayName;
        this.modify("display_name", displayName);
        return this;
    }

    /**
     * 设置 [DC]
     */
    public SysDeploySystem setDc(String dc) {
        this.dc = dc;
        this.modify("dc", dc);
        return this;
    }

    /**
     * 设置 [菜单]
     */
    public SysDeploySystem setMenus(List<SysMenu> menus) {
        this.menus = menus;
        this.modify("menus", menus);
        return this;
    }

    /**
     * 设置 [组件]
     */
    public SysDeploySystem setComponents(List<SysComponent> components) {
        this.components = components;
        this.modify("components", components);
        return this;
    }

    /**
     * 设置 [接口]
     */
    public SysDeploySystem setApis(List<SysApi> apis) {
        this.apis = apis;
        this.modify("apis", apis);
        return this;
    }

    /**
     * 设置 [权限资源]
     */
    public SysDeploySystem setPermissions(List<SysPermission> permissions) {
        this.permissions = permissions;
        this.modify("permissions", permissions);
        return this;
    }

    /**
     * 设置 [自定义资源]
     */
    public SysDeploySystem setCustomResources(List<SysCustomResource> customResources) {
        this.customResources = customResources;
        this.modify("custom_resources", customResources);
        return this;
    }

    /**
     * 设置 [MD5校验]
     */
    public SysDeploySystem setMd5Checksum(String md5Checksum) {
        this.md5Checksum = md5Checksum;
        this.modify("md5_checksum", md5Checksum);
        return this;
    }

    /**
     * 设置 [绑定标识]
     */
    public SysDeploySystem setBindingId(String bindingId) {
        this.bindingId = bindingId;
        this.modify("binding_id", bindingId);
        return this;
    }

    /**
     * 设置 [描述]
     */
    public SysDeploySystem setDescription(String description) {
        this.description = description;
        this.modify("description", description);
        return this;
    }

    /**
     * 设置 [是否启用标识]
     */
    public SysDeploySystem setEnabled(Integer enabled) {
        this.enabled = enabled;
        this.modify("enabled", enabled);
        return this;
    }


    @Override
    public Serializable getDefaultKey(boolean gen) {
        //Assert.notNull(getSystemId(),"未设置系统名");
        //Assert.notNull(getDc(),"未设置DC");
        String key = String.format("%s||%s"
            ,getSystemId(),getDc());
        key = DigestUtils.md5DigestAsHex(key.getBytes());    
        return key;
    }

    /**
     * 复制当前对象数据到目标对象(粘贴重置)
     * @param targetEntity 目标数据对象
     * @param includeEmpty  是否包括空值
     * @param <T>
     * @return
     */
    @Override
    public <T> T pasteTo(T targetEntity, boolean includeEmpty) {
        super.pasteTo(targetEntity, includeEmpty);
        if(targetEntity instanceof IEntity) {
            IEntity entity = ((IEntity) targetEntity);
            entity.reset("id");
        }
        return targetEntity;
    }

}